package com.webchat.aigc.controller.javasse;

import com.webchat.common.config.annotation.ValidateLogin;
import com.webchat.common.helper.SseEmitterHelper;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@RestController
@RequestMapping("/aigc-service/event/")
public class EventStreamConnectController {

    /**
     * 获取SSE链接对象
     *
     * @param request
     * @return
     */
    @ValidateLogin
    @GetMapping(path = "/stream", produces = "text/event-stream")
    public SseEmitter stream(HttpServletRequest request) {
        String biz = request.getParameter("bizCode");
        String userId = request.getParameter("userId");
        return SseEmitterHelper.get(biz, userId);
    }
}
